<?php
/** WordPress Administration Bootstrap */
require_once('./admin.php');
global $wpdb;

$e = new nmFileUploader;

/*
set status
*/
if($_GET['status'] != '')
{
	$e -> setStatus($_GET['status'], $_GET['id']);
}
/*
Bulk Action Delete
*/
if(isset($_GET['listings']))
{
	$e -> deleteListing($_GET['listings']);
}
if(@$_GET['action'] == 'delete')
{
	$e -> deleteListing($_GET['listing']);
}


$arrListings = $wpdb -> get_results( "SELECT * FROM ".$wpdb->prefix . "propertylisting");


//print_r($arrListings);
?>

<link rel="stylesheet" type="text/css" href="<?php echo plugins_url('js/fancybox/jquery.fancybox-1.3.4.css', __FILE__)?>" media="screen" />
<div id="wpbody-content">
  <div class="wrap">
	<div class="icon32" id="icon-users"><br></div>
<h2>Files Uploaded</h2>

<div class="filter">
<!--<form method="get" action="" id="list-filter">
<ul class="subsubsub">
<li><a class="current" href="javascript:alert('Men at work')">All <span class="count">(2)</span></a> |</li>
<li><a href="javascript:alert('Men at work')">PDFs</a> |</li>
<li><a href="javascript:alert('Men at work')">Images</a></li>
</ul>
</form>-->
</div>
<form method="get" action="" id="posts-filter">
  <input type="hidden" name="page" value="property-listings" />


	
<style>
.column-listing-id
{
	width:25px;
}
</style>

	
<table width="453" cellspacing="0" class="widefat fixed">
<thead>
<tr class="thead">
	<th width="18" class="manage-column column-listing-id" id="id" style="" scope="col">ID</th>
    <th width="238" class="manage-column column-title" id="title" style="" scope="col">Posted by</th>
	<th width="109" class="manage-column column-detail" id="detail" style="" scope="col">Detail</th>
	<th width="70" class="manage-column column-views num" id="views" style="" scope="col">Views</th>
</tr>
</thead>

<tfoot>
<tr class="thead">
	<th style="" class="manage-column column-id" id="id" scope="col">ID</th>
    <th style="" class="manage-column column-title" id="title" scope="col">Posted by</th>
	<th style="" class="manage-column column-detail" id="detail" scope="col">Detail</th>
	<th style="" class="manage-column column-views num" id="payment" scope="col">Payment Status</th>
</tr>
</tfoot>

<tbody class="list:user user-list" id="property-listings">
	<?php
	foreach($arrListings as $list):
	$postedby = $list -> property_firstname.' posted new property';
	$detail = $list -> property_detail;
	$urlDel = ADMINLISTING.'&action=delete&listing='.$list -> property_ID;
	$urlStatusAccept = ADMINLISTING.'&status=Approved&id='.$list -> property_ID;
	$urlStatusReject = ADMINLISTING.'&status=Rejected&id='.$list -> property_ID;
	
	$arrImages = explode(',', $list -> property_images);
	$urlImage = get_bloginfo('template_url') . '/uploads/'.$arrImages[0];
	
	$isPaid = ($list -> property_fee_paid == 1) ? '<span style="color:green">Paid</span>' : '<span style="color:red">Not</span>';
	//echo 'url '.$urlImage;	
	?>

	<tr class="alternate" id="user-<?php echo $list -> property_ID	?>">
    <td class="listing-id"><?php echo $list -> property_ID	?></td>
    
    <td class="username column-username">
    <!--<a href="<?= $urlImage?>" rel="example_group">
    <img width="50" height="50" class="avatar avatar-32 photo" src="<?= $urlImage?>" alt="example1"> 
    </a>-->
    <!-- rest images -->
    <?php foreach($arrImages as $image):
	$urlImage = get_bloginfo('template_url') . '/uploads/'.$image;
	?>
    <a href="<?= $urlImage?>" rel="example_group_<?= $list -> property_ID?>">
    <img width="50" height="50" class="avatar avatar-32 photo" src="<?= $urlImage?>" > 
    </a>
    <script type="text/javascript">
	$("a[rel=example_group_<?= $list -> property_ID?>]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
	</script>
    <?php endforeach;?>
    <strong>
    <a href="javascript:alert('Men at work')"><?php echo $postedby?></a></strong><?= $list -> property_status?><br>
    
    <div class="row-actions">
    	<!--<span class="edit"><a href="profile.php">Edit</a></span> |-->
        <span class="delete">
        	<a href="javascript:confirmFirst('<?= $urlDel?>')">Delete</a> |
        </span>
        <span class="edit">
            <a href="javascript:confirmFirst('<?= $urlStatusAccept?>')">Download</a></span></div></td>
    
    <td valign="top" class="name column-name"><?php echo $detail?>
    <a href="javascript:showDetail(<?php echo $list -> property_ID	?>)">Show Detail</a>
    <br />
    <span id="detail-all-<?= $list -> property_ID?>" class="detail-all" style="display:none">
    Price: <?= $list -> property_price?><br />
    Postcode: <?= $list -> property_postcode?><br />
    Rooms: <?= $list -> property_rooms?><br />
    Area: <?= $list -> property_area?><br />
    Number of Sleeps: <?= $list -> property_sleeps?><br />
    Closest Tube: <?= $list -> property_closest_tube?><br />
    Property Type: <?= $list -> property_type?><br />
    Pets: <?= $list -> property_pets?><br />
    Smoking: <?= $list -> property_smoking?><br />
    Deposit Info: <?= $list -> property_deposit_info?><br />
    
    Internet: <?= $list -> property_internet?><br />
    Wifi: <?= $list -> property_wifi?><br />
    Kitchen: <?= $list -> property_kitchen?><br />
    Garden: <?= $list -> property_garden?><br />
    Disabled Access: <?= $list -> property_disabled_access?><br />
    Cabel: <?= $list -> property_cable?><br />
    TV: <?= $list -> property_tv?><br />
    BBQ: <?= $list -> property_BBQ?><br />
    <h4>Profile</h4>
    Firsname: <?= $list -> property_firstname?><br />
    Surname: <?= $list -> property_surname?><br />
    Telephone: <?= $list -> property_telephone?><br />
    Email: <?= $list -> property_email1?>
    
    
    </span>
    </td>
    
    <td class="posts column-view num"><a class="edit" title="Viewed how many times" href="edit.php?author=1"> <?= $isPaid?> </a></td></tr>
    
    <?php
	endforeach;
	?>
    
    </tbody>
</table>

<div class="tablenav">


<!--<div class="alignleft actions">
<select name="action2">
<option selected="selected" value="">Bulk Actions</option>
<option value="delete">Delete</option>
</select>
<input type="submit" class="button-secondary action" id="doaction2" name="doaction2" value="Apply">
</div>-->

<br class="clear">
</div>


</form>
</div>


<br class="clear">

<div class="clear"></div></div>

